Listing 3. Listing of CDADETextReader.zi



Deck "CDADETextReader"
  Card "TextReader"
    BeforeAttachment
      Nop ;The following lines are directives to CD_ADE
      Let CD_ADE_Version = "" ; version 1.00
      Nop ; CD_ADE_Icons = TRUE
      If Invocation=0
        MakeDocument "TextDoc"
        Let WW=320
        Let WH=200
        Let WX=108
        Let WY=44
      EndIf
      Let Invocation=1
    EndScript
    AfterAttachment
      SetWindowLimits 200,100,9999,9999
    EndScript
    Window "UserWindow"
      Definition
        Origin WX,WY
        Size WW,WH
        Title "CD_ADE Text File Reader"
        NumberOfColors 4,69632
        DefaultColors 0,1,0
        WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR SIZEBUTTON 
        WindowFlags ACTIVATE TOFRONT WORKBENCH 
        VisualEffects NONE ,WAIT 
      EndScript
      OnCloseButton
        Quit
      EndScript
      OnResized
        Let WX=WindowX
        Let WY=WindowY
        Let WW=WindowWidth
        Let WH=WindowHeight
        GotoCard "TextReader"
      EndScript
    EndObj
    Memo "FileMemo"
      Definition
        Origin 10,16
        Size WindowWidth-35,WindowHeight-50
        Font "topaz",8
        Style PLAIN ,2,3
        TextColors 1,0,JAM2 
        Border DOUBLEBEVEL ,2,1
        MemoDocument "TextDoc"
        ScrollBars RIGHT 
        InputStyle NORMAL 
      EndScript
    EndObj
    TextButton "SelectFile"
      Definition
        Origin (WindowWidth%2)-95,WindowHeight-20
        Font "topaz",11
        Style BOLD SHADOW ,2,3
        TextColors 1,0,JAM1 
        Text " Select File to View "
        Border BEVEL ,2,1
        Highlight COMPLEMENT 
        ButtonFlags NONE 
      EndScript
      OnRelease
        Let Heading="Select a text file to view"
        Let FNNew=AskForFileName(FN,Heading,WindowX+100,WindowY+100)
        If FNNew<>""
          Let FN=FNNew
          OpenFile FN,"FileBuf",READONLY ,OLDFILE 
          GetFileInfo FN,FNSize
          FileReadChars "FileBuf",TextVar,FNSize
          Close "FileBuf"
          Clear DOCUMENT 
          Type TextVar
          MoveCursorTo STARTOF DOCUMENT 
        EndIf
      EndScript
    EndObj
  EndObj
EndObj
